package Leetcode.LeetcodeDemo1;

public class LeetCode88 {
    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        int[] num=new int[m+n];
        int i=0;
        int index1=0;
        int index2=0;
        while(index1<m&&index2<n){
            num[i++]=nums1[index1]<nums2[index2]?nums1[index1++]:nums2[index2++];
        }
        while(index1<m){
            num[i++]=nums1[index1++];
        }
        while(index2<n){
            num[i++]=nums2[index2++];
        }
        for(i=0; i<n+m;i++){
            System.out.print(num[i]+" ");
        }
    }

    public static void main(String[] args) {
        int[] nums1={1,2,3,0,0,0};
        int[] nums2={2,3,4};
        merge(nums1,3,nums2,3);
    }
}
